package com.hd123.rumba.gwt.widget2.client.fielddef;

/**
 * 布尔类型字段的定义
 * 
 * @author LiQi
 * 
 */
public class BooleanFieldDef extends FieldDef {

  public static final String VALUE_TEXT_TRUE = "是";
  public static final String VALUE_TEXT_FALSE = "否";

  public BooleanFieldDef(String name, String caption, boolean nullable) {
    super(name, caption, nullable);
  }

  public FieldDef clone() {
    return new BooleanFieldDef(name, caption, nullable);
  }

  public boolean validateText(String text, StringBuffer message, boolean checkNullable) {
    if (text == null || text.equals(VALUE_TEXT_FALSE) || text.equals(VALUE_TEXT_TRUE))
      return super.validateText(text, message, checkNullable);
    else {
      finalizeMessage(message, "\"" + text + "\"不在可选值范围内");
      return false;
    }
  }

}
